import request from '@/utils/request'

// 获取SNMP通用参数
export function getSnmp (params) {
  var data = fromData(params)
  return request({
    url: '/snmp/getSnmp',
    method: 'post',
    data
  })
}

// SNMP--编辑SNMP参数
export function editSnmp (params) {
  var data = fromData(params)
  return request({
    url: '/snmp/editSnmp',
    method: 'post',
    data
  })
}

// SNMP--切换SNMP状态
export function snmpSwitch (params) {
  var data = fromData(params)
  return request({
    url: '/snmp/snmpSwitch',
    method: 'post',
    data
  })
}

// 清空SNMP通用参数
export function clearSnmp (params) {
  var data = fromData(params)
  return request({
    url: '/snmp/clearSnmp',
    method: 'post',
    data
  })
}

function fromData (params) {
  let formData = new FormData()
  for (const it in params) {
    if (!Object.is(params[it], null) && !Object.is(params[it], '')) {
      formData.append(it, params[it])
    }
  }
  return formData
}
